//
//  YSWaveInfoViewController.m
//  YSKitDemo
//
//  Created by Kyson on 2019/1/15.
//  Copyright © 2019 YangShen. All rights reserved.
//

#import "YSWaveInfoViewController.h"
#import "YSWavesView.h"

@interface YSWaveInfoViewController ()

@end

@implementation YSWaveInfoViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
   
    [self setupHeaderView];
}


- (void)setupHeaderView {
    [self.contentView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(self.mas_bottomLayoutGuideTop);
    }];
    
    CGFloat tableHeaderViewX = 0;
    CGFloat tableHeaderViewY = 0;
    CGFloat tableHeaderViewW = self.view.bounds.size.width;
    CGFloat tableHeaderViewH = 200;
    UIView *tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(tableHeaderViewX, tableHeaderViewY, tableHeaderViewW, tableHeaderViewH)];
    self.tableView.tableHeaderView = tableHeaderView;
    
    YSWavesView *waveView = [[YSWavesView alloc] initWithFrame:CGRectMake(tableHeaderViewX, tableHeaderViewY, tableHeaderViewW, tableHeaderViewH)];
    waveView.backgroundColor = [UIColor ys_colorFromHexString:@"4bccbc"];
    [waveView startWaveAnimation];
    [self.tableView.tableHeaderView addSubview:waveView];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellID = @"cellID";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    
    cell.textLabel.text = @"退出";
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    [self.navigationController popViewControllerAnimated:YES];
}

@end
